Optimal. Leaf size=76 \[ -\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.13, antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 7, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3979, 4136,
3855, 4004, 3916, 2738, 214} \begin {gather*} -\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d}-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 214
Rule 2738
Rule 3855
Rule 3916
Rule 3979
Rule 4004
Rule 4136
Rubi steps
\begin {align*} \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx &=\int \frac {-1+\sec ^2(c+d x)}{a+b \sec (c+d x)} \, dx\\ &=\frac {\int \sec (c+d x) \, dx}{b}+\frac {\int \frac {-b-a \sec (c+d x)}{a+b \sec (c+d x)} \, dx}{b}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\left (\frac {a}{b}-\frac {b}{a}\right ) \int \frac {\sec (c+d x)}{a+b \sec (c+d x)} \, dx\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {\left (\frac {a}{b}-\frac {b}{a}\right ) \int \frac {1}{1+\frac {a \cos (c+d x)}{b}} \, dx}{b}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {\left (2 \left (\frac {a}{b}-\frac {b}{a}\right )\right ) \text {Subst}\left (\int \frac {1}{1+\frac {a}{b}+\left (1-\frac {a}{b}\right ) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b d}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.16, size = 115, normalized size = 1.51 \begin {gather*} -\frac {b c+b d x-2 \sqrt {a^2-b^2} \tanh ^{-1}\left (\frac {(-a+b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )+a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )}{a b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.13, size = 108, normalized size = 1.42
method | result | size |
derivativedivides | \(\frac {-\frac {2 \left (a +b \right ) \left (a -b \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b a \sqrt {\left (a +b \right ) \left (a -b \right )}}+\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b}}{d}\) | \(108\) |
default | \(\frac {-\frac {2 \left (a +b \right ) \left (a -b \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b a \sqrt {\left (a +b \right ) \left (a -b \right )}}+\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b}}{d}\) | \(108\) |
risch | \(-\frac {x}{a}-\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i \sqrt {a^{2}-b^{2}}+b}{a}\right )}{d b a}+\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i \sqrt {a^{2}-b^{2}}-b}{a}\right )}{d b a}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{b d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{b d}\) | \(157\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 4.50, size = 253, normalized size = 3.33 \begin {gather*} \left [-\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) - \sqrt {a^{2} - b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right )}{2 \, a b d}, -\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, \sqrt {-a^{2} + b^{2}} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right )}{2 \, a b d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\tan ^{2}{\left (c + d x \right )}}{a + b \sec {\left (c + d x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 140 vs.
\(2 (67) = 134\).
time = 0.62, size = 140, normalized size = 1.84 \begin {gather*} -\frac {\frac {d x + c}{a} - \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{b} + \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{b} + \frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )} {\left (a^{2} - b^{2}\right )}}{\sqrt {-a^{2} + b^{2}} a b}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 1.63, size = 121, normalized size = 1.59 \begin {gather*} \frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d}-\frac {2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{a\,d}-\frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a+b\right )}\right )\,\sqrt {a^2-b^2}}{a\,b\,d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________